package leetcode.easy.numberofspecialchars;

import java.util.HashSet;
import java.util.Set;

public class Solution {
    public int numberOfSpecialChars(String word) {
        Set<Character> uppers = new HashSet<>();
        for (int i = 0; i < word.length(); i++) {
            char c = word.charAt(i);
            if (Character.isUpperCase(c)) {
                uppers.add(c);
            }
        }
        Set<Character> magic = new HashSet<>();
        for (int i = 0; i < word.length(); i++) {
            char c = word.charAt(i);
            if (Character.isLowerCase(c)) {
                if (uppers.contains(Character.toUpperCase(c))) {
                    magic.add(c);
                }
            }
        }
        return magic.size();
    }

    public static void main(String[] args) {
        String word = "abc";
        System.out.println(new Solution().numberOfSpecialChars(word));
    }
}
